//
//  CRNewsDetailViewController.m
//  NewAge
//
//  Created by dllo on 15/11/29.
//  Copyright © 2015年 ColorRevolution. All rights reserved.
//

#import "CRNewsDetailViewController.h"



@interface CRNewsDetailViewController ()<UIWebViewDelegate, NSCoding>

{
    UIView *_bgView;
}

@property (nonatomic, strong) UIWebView *detailWebView;
@property (nonatomic, strong) UIActivityIndicatorView *aiView;

@end

@implementation CRNewsDetailViewController



- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
    
    self.navigationController.navigationBar.hidden = NO;
    
    [MBProgressHUDManager showHUDtoView:self.view string:@"加载中.."];
    
    self.detailWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:_detailWebView];
    _detailWebView.scrollView.bounces = NO;
    _detailWebView.scrollView.backgroundColor = [UIColor blackColor];
    _detailWebView.backgroundColor = [UIColor blackColor];
    _detailWebView.delegate = self;
    _detailWebView.scalesPageToFit = YES;
    
    self.aiView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 32.0f, 32.0f)];
    _aiView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
    _aiView.center = self.view.center;
    [self.view addSubview:_aiView];
    NSURL *url = [NSURL URLWithString:self.str];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [_detailWebView loadRequest:request];
    
    _bgView = [[UIView alloc] init];
    
    _bgView.backgroundColor = [UIColor blackColor];
    _bgView.alpha = 0.3;
    [self.detailWebView.scrollView addSubview:_bgView];
    
//    [view mas_makeConstraints:^(MASConstraintMaker *make) {
//        EDGES(self.detailWebView.scrollView, 0, 0, 0, 0);
//    }];
    

}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    [MBProgressHUDManager removeHUD];
    
//    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//    CGRect frame = webView.frame;
//    //webView的宽度
//    webView.frame = frame;
//    float content_height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] floatValue];
//    frame = webView.frame;
//    //webView的宽度和高度
//    frame.size = CGSizeMake(WIDTH, webView.scrollView.contentSize.height + 40);
////    webView.frame = frame;
//    
////    _bgView.frame = frame;
//    
//    NSLog(@"-----%g", webView.scrollView.contentSize.height);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
